package com.qst.express.controller.wx;

import com.qst.express.utils.wx.SignatureUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author:CoolTiger
 * @title: WXConfig
 * @projectName springboot-e
 * @description: TODO
 * @date:2022/10/17/20:27:40
 **/
@Controller
@RequestMapping("/e")
public class WXConfig {
    @RequestMapping("/wxconf")
    public void WXJs(@RequestParam("xurl") String urlText, HttpServletResponse response, HttpServletRequest request) throws IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        System.out.println("WXConfig===-------------------------------------------------------"+urlText);
        PrintWriter pw = response.getWriter();
        try {
            String json = SignatureUtil.getConfig(urlText).toJSON();
            pw.println(json);
        } catch (Exception e) {
            e.printStackTrace();
        }
        pw.close();
    }
}
